
package controler;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Vector;

/**
 * <p>Title: controler.Case </p>
 *
 * <p>
 * 	Description: La classe case du controler definit de maniere logique une case
 *  C'est a dire son theme, sa couleur, ses coordonnees (distance et angle)
 * </p>
 *
 * <p>Copyright: (c) 2008 FSSIM</p>
 *
 * <p>Company: FSSImock</p>
 *
 * @author Antoine Farnault
 * @author Augustin Couette
 * @version 1.0
 */
public class Case {
	public int id;
	public double a,b; //les 2 angles
	public int h;
	public int d;
	public boolean isCamembert;
	public Color couleur;
	public ArrayList<Integer> voisins;
	
	public int x, y , diametre, startAngle, angleWidth;
	public Vector<String> pions = new Vector<String>(); //les pions sur cette case
	
	
	/**
	 * Constructeur de case
	 * @param id numero id
	 * @param a angle de debut
	 * @param b angle de fin
	 * @param d distance du centre.
	 * @param h hauteur de la case
	 * @param camembert true si c'est un camembert
	 * @param Color couleur
	 */
	public Case(int id, double a,double b,int d,int h, boolean camembert, Color couleur){
		this.id = id; 
		this.a  = a;
		this.b  = b;
		this.h  = h;
		this.d  = d;
		this.isCamembert = camembert;
		this.couleur = couleur;
	}

	/**
	 * Affichage sous forme de chaine d'une case
	 * @return String la chaine 
	 */
	public String toString(){
		return "id : "+id+" c:"+couleur+"  a: "+a+"  b : "+b+"  d:"+d+"  camembert: "+isCamembert+"  h:"+h;
	}


	public Case(int numero) {
		this.id = numero;
		voisins = new ArrayList<Integer>();
		isCamembert = false;
		switch (numero) {
		case 0:
			for (int i = 1; i < 27; i = i + 5)
				voisins.add(i);
			break;
		case 5://les cases avant les camemberts des rayons du plateau
		case 10:
		case 15:
		case 20:
		case 25:
		case 30:
			voisins.add(numero - 1);
			//calcul des cases camembert
			voisins.add(26 + numero + ((numero / 5) - 1) * 2);
			break;
		case 31:
		case 38:
		case 45:
		case 52:
		case 59:
		case 66:
			voisins.add(5 * ((numero - 31) / 7 + 1));
			voisins.add(numero + 1);
			if (numero == 31) {
				voisins.add(72);
			} else {
				voisins.add(numero - 1);
			}
			isCamembert = true;
			break;
		case 1:
		case 6:
		case 11:
		case 16:
		case 21:
		case 26:
			voisins.add(0);
			voisins.add(numero + 1);
			break;
		case 72:
			voisins.add(31);
			voisins.add(numero - 1);
			break;
		default:
			voisins.add(numero - 1);
		voisins.add(numero + 1);

		}
		switch(numero) {
		case 1://CASES VERTES
		case 35:
		case 9:
		case 44:
		case 46:
		case 15:
		case 18:
		case 55:
		case 22:
		case 66:
			couleur = Color.green;
			break;
		case 2://CASE BLEUE
		case 38:
		case 11:
		case 49:
		case 19:
		case 58:
		case 60:
		case 25:
		case 28:
		case 69:
			couleur = Color.blue;
			break;
		case 3://CASES ORANGE
		case 34:
		case 7:
		case 16:
		case 24:
		case 56:
		case 65:
		case 67:
		case 30:
		case 45:
			couleur = Color.orange;
			break;
		case 4://CASES ROSE
		case 10:
		case 37:
		case 39:
		case 13:
		case 48:
		case 17:
		case 59:
		case 26:
		case 70:
			couleur = Color.pink;
			break;
		case 5://CASES JAUNE
		case 72:
		case 32:
		case 8:
		case 41:
		case 12:
		case 52:
		case 21:
		case 63:
		case 29:
			couleur = Color.yellow;
			break;
		case 31://CASES MARRON
		case 6:
		case 42:
		case 14:
		case 51:
		case 53:
		case 23:
		case 62:
		case 27:
		case 20:
			couleur = Color.red;
			break;
		case 0:
			couleur = Color.black;
			break;
		default:
			couleur = Color.cyan; 
		}
	}




	public Color getColor() {
		return couleur;
	}

	public void afficheVoisins() {
		for (int i = 0; i < getNbVoisin(); i++)
			System.out.print(voisins.get(i) + " ");
		System.out.println();
	}

	public int getNbVoisin() {
		return voisins.size();
	}

	public int getVoisin(int i) {
		return voisins.get(i);
	}

	public int getNumero(){
		return id;
	}
	public boolean isCaseCamembert() {
		return isCamembert;
	}
}





